﻿using Bottle.CommunityForum.Common;
using Bottle.CommunityForum.Model;
using Bottle.CommunityForum.UIPortal.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Bottle.CommunityForum.UIPortal.Controllers
{
    public class BaseController : Controller
    {
        //
        // GET: /Base/

        public readonly int delError = (int)Bottle.CommunityForum.Model.Enum.ResultEnum.Error;

        public readonly int delSuccess = (int)Bottle.CommunityForum.Model.Enum.ResultEnum.Success;

        public readonly int delCrudAdd = (int)Bottle.CommunityForum.Model.Enum.CrudEnum.Add;

        public readonly int delCrudEdit = (int)Bottle.CommunityForum.Model.Enum.CrudEnum.Edit;

        /// <summary>
        /// 登录头部信息
        /// </summary>
        /// <returns></returns>
        public PartialViewResult HeaderForLogIn()
        {
            UserViewModel userModel = JsonConvert.DeserializeObject<UserViewModel>(AspFormsAuthentication.getUserInfo());
            return PartialView("_HeaderForLogIn", userModel);
        }

        /// <summary>
        /// 是否已登录
        /// </summary>
        /// <returns></returns>
        protected bool IsLogin
        {
            get
            {
                return HttpContext.User.Identity.IsAuthenticated;
            }
        }

        /// <summary>
        /// 最新热贴TOP10
        /// </summary>
        /// <returns></returns>
        public PartialViewResult loadHotPostTopTen()
        {
            return PartialView("_HotPost");
        }

        /// <summary>
        /// 最新热议TOP10
        /// </summary>
        /// <returns></returns>
        public PartialViewResult LoadHotCommentTopTen()
        {
            return PartialView("_HotConmment");
        }

        /// <summary>
        /// 推荐干货
        /// </summary>
        /// <returns></returns>
        public PartialViewResult LoadLinks()
        {
            return PartialView("_Link");
        }

        /// <summary>
        /// 月雷锋榜TOP12
        /// </summary>
        /// <returns></returns>
        public PartialViewResult LoadContributionTopTwelve()
        {
            return PartialView("_Contribution");
        }

        /// <summary>
        /// 广告位
        /// </summary>
        /// <returns></returns>
        public PartialViewResult LoadAdvertising()
        {
            return PartialView("_Advertising");
        }
    }
}
